package com.wf.demo.info.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

import com.wf.demo.info.pojo.Company;
import com.wf.demo.job.pojo.DataDevice;
import lombok.Data;

@Data
@Entity
@Table(name="info_device")
@JsonIgnoreProperties({ "handler","hibernateLazyInitializer" })
public class Device{

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="id")
    private Long id;

    @ManyToOne
    @JoinColumn(name = "cid")
    private Company company;    //对应的公司外键

    @ManyToOne
    @JoinColumn(name = "mid")
    private Model model;        //对应的机型外键

    @Column(name="csNumber")
    private String csNumber;

    @Column(name="beidouId")
    private Long beidouId;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
    private LocalDate factoryDate;         //出厂日期

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
    private LocalDate startDate;      //postman返回的"2019-10-05"

    private Long serviceLife;

    @Column(name="isOnline")
    private boolean isOnline;       //在数据库里0，postman返回为false，大于等于1返回true  为什么没有is????

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastTime;  //最新一次更新数据（在线）的时间

    private Long onlineTime;

    @Column(name = "status")
    private int status;         //对应数据库tinyint

    @Column(name = "rotateStatus")
    private int rotateStatus;         //对应数据库tinyint    发动机旋转状态，默认1在转动，0为停止转动，2是正在执行

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime scrapTime;          //postman返回的"2019-10-05 "

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;      //录入数据库时在controller自动生成

    @Column(name = "ipPort")
    private String ipPort;   //5G客户端的地址
    @Transient
    private List<DataDevice> dataDevices;   //设备数据的集合


}